package Messages;

public class Util {
	public static Message GetMessageObject(String message) throws InvalidVarListException
	{
		if(message.startsWith("alert:entrantDetected,"))
			return new EntrantDetected(message.substring("alert:entrantDetected".length()));
		
		if(message.startsWith("alert:canceled,"))
			return new AlertCanceled(message.substring("alert:canceled".length()));
		
		if(message.startsWith("alert:invalidKey;"))
			return new InvalidKey();
		
		if(message.startsWith("command:door,"))
			return new DoorCommand(message.substring("command:door".length()));
		
		if(message.startsWith("command:c2DMRegistration,"))
			return new C2DMRegistration(message.substring("command:c2DMRegistration".length()));
		
		if(message.startsWith("config:regenerateKey,"))
			return new KeyGeneration(message.substring("config:regenerateKey".length()));
		
		if(message.startsWith("config:newKey,"))
			return new KeyGenerationResponse(message.substring("config:newKey".length()));
		
		return null;
	}
}
